package com.cn.netty.basic;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ThreadUtils;

@Slf4j
public class EchoServerOutboundHandlerZero extends ChannelOutboundHandlerAdapter {

    @Override
    public void read(ChannelHandlerContext ctx) throws Exception {
        log.warn("read event");
        super.read(ctx);
    }

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        //每执行一次write(),我都要触发一次
        log.warn("write event -> {} {}", this, String.valueOf(msg));
        Thread.sleep(2000);
        super.write(ctx, msg, promise);
    }

}
